﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典明细管理</title>
    <#include "../common/link.ftl">
    <script>
        $(function () {
            $('.btn_input').click(function () {
                var data = $(this).data('json');
                $('.modal-title').html('字典明细添加')

                var $li=$('#systemDictionaries>li.active');
                var id=$li.attr('systemDictionaryId')
                var title=$li.html();
                console.log(id,title);

                var $option=$('[name="systemDictionary.id"]>option')
                console.log($option);
                $option.val(id)
                $option.html(title)

                $('#editForm')[0].reset();
                if (data) {
                    $('.modal-title').html('字典明细编辑')
                    $('input[name="id"]').val(data.id);
                    $('input[name="title"]').val(data.title);
                    $('input[name="sequence"]').val(data.sequence);
                    $option.val(data.systemDictionaryId);
                    $option.html(data.systemDictionaryTitle);
                }
                $('#editModal').modal('show');
            });
            $('.btn-submit').click(function () {
                $('#editForm').ajaxSubmit(function (data) {
                    if (data.success) {
                        $.messager.confirm("温馨提示", data.msg, function () {
                            window.location.reload();
                        })
                    } else {
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })

        })
    </script>
    <script>
        $(function () {
            $('.systemDictionary').click(function () {
                var id=$(this).attr('systemDictionaryId');
                $('#parentId').val(id)
                $('#searchForm').submit()
            })
        })
    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <<#assign currentMenu='systemDictionaryItem'>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典明细管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <div class="row box-body">
                    <div class="col-md-3">
                        <ul id="systemDictionaries" class="list-group">
                        </ul>
                        <ul id="systemDictionaries" class="list-group">
                            <#list systemDictionaries as systemDictionary>
                                <li class="list-group-item systemDictionary <#if qo.parentId?? && qo.parentId == systemDictionary.id>active</#if>"
                                    systemDictionaryId="${systemDictionary.id}">${systemDictionary.title}</li>
                            </#list>
                        </ul>
                    </div>
                    <div class="col-md-9">
                        <!--高级查询--->
                        <form class="form-inline" id="searchForm" action="/systemDictionaryItem/list.do" method="post">
                            <input type="hidden" name="currentPage" id="currentPage" value="1">
                            <input type="hidden" name="parentId" id="parentId" value="${(qo.parentId)!}">
                            <#if qo.parentId??>
                                 <a data-url="/systemDictionaryItem/input.do" class="btn btn-success btn_input">
                                     <span class="glyphicon glyphicon-plus"></span> 添加
                                 </a>
                            </#if>
                        </form>
                        <!--编写内容-->
                        <div class="table-responsive no-padding ">
                            <table class="table table-hover table-bordered">
                                <tr>
                                    <th>编号</th>
                                    <th>字典目录</th>
                                    <th>标题</th>
                                    <th>序列</th>
                                    <th>操作</th>
                                </tr>

                                <#list pageInfo.list as systemDictionaryItem>
                                    <tr>
                                        <td>${systemDictionaryItem_index + 1}</td>
                                        <td>${systemDictionaryItem.systemDictionary.title}</td>
                                        <td>${systemDictionaryItem.title}</td>
                                        <td>${systemDictionaryItem.sequence}</td>
                                        <td>
                                            <#if qo.parentId??>
                                                 <a data-json='${systemDictionaryItem.jsonData}'
                                                    class="btn btn-info btn-xs btn_input">
                                                     <span class="glyphicon glyphicon-pencil"></span> 编辑
                                                 </a>
                                            </#if>
                                            <a data-url="/systemDictionaryItem/delete.do" data-id='${systemDictionaryItem.id}'
                                               class="btn btn-danger btn-xs btn-delete">
                                                <span class="glyphicon glyphicon-trash"></span> 删除
                                            </a>
                                        </td>
                                    </tr>
                                </#list>
                            </table>
                            <!--分页-->
                            <#include "../common/page.ftl">
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
<!---字典明细编辑--->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">字典明细编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionaryItem/saveOrUpdate.do" method="post"
                      id="editForm">
                    <input type="hidden" value="" name="id">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">目录：</label>
                        <div class="col-sm-6">
                           <select class="form-control" name="systemDictionary.id" readonly>
                               <option></option>
                           </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title" value="" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">序列：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sequence" value="" placeholder="请输入">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary btn-submit">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
